<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>时间过滤器封装</title>
</head>

<body>
  <div id="app">
    <ul>
      <li v-for="item in newsData">{{ item.title }}---{{item.time | dataFomate}}</li>
    </ul>
  </div>
  <script src="vue.js"></script>
  <script>
    new Vue({
      el: '#app',
      data: {
        newsData: [
          { id: 'a01', title: '我是新闻111', time: 1325431108758 },
          { id: 'a02', title: '我是新闻121', time: 1165431108258 },
          { id: 'a051', title: '我是新闻131', time: 7745431108858 },
          { id: 'a08', title: '我是新闻141', time: 3395431108958 },
        ]
      },
      filters: {
        dataFomate(e) {
          let a = new Date(e).toLocaleString();
          return a;
        }
      },
      methods: {

      }
    })
  </script>
</body>

</html>